import axios from 'axios';
import * as actionType from './actionTypes';

const changeDetail = (title, content) => ({
  type: actionType.CHANGE_DETAIL,
  title,
  content
});

export const detailAjax = (id) => {
  return (dispatch) =>{
    axios.get('/api/detail.json?id=' + id).then(res => {
      let data = res.data.data;
      dispatch(changeDetail(data.title, data.content))
    })
  }
};